package com.ty.user.starter.entity.dto;

import com.ty.user.starter.entity.User;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.multipart.MultipartFile;

import java.io.Serializable;

@Validated
@Data
public class UserDto implements Serializable {

    private static final long serialVersionUID = -6606385624303617791L;

    @ApiModelProperty("id")
    private Long id;

    @ApiModelProperty("部门id")
    private Long deptId;

    @ApiModelProperty(value = "用户名", required = true)
    @NotBlank(message = "用户名不能为空")
    @Length(min = 6, max = 20, message = "用户名长度介于6~20位")
    private String username;

    /**
     * 与user表中的pwd进行区分,利用业务逻辑实现
     * @see User#getPwd()
     */
    @ApiModelProperty(value = "密码", required = true)
    @NotBlank(message = "密码不能为空")
    @Length(min = 8, max = 20, message = "密码长度介于8~20位")
    private String password;

    @ApiModelProperty("联系人")
    @Length(min = 1, max = 20, message = "联系人长度不能大于20位")
    private String realName;

    @ApiModelProperty("联系地址")
    @Length(min = 1, max = 20, message = "地址长度不能大于100位")
    private String address;

    @ApiModelProperty("电话号码")
    @Length(min = 7, max = 11, message = "电话号码长度介于7~12位")
    private String phone;

    @ApiModelProperty("身份证号码")
    @Length(min = 5, max = 18, message = "身份证号码长度介于5~18位")
    private String idCard;

    @ApiModelProperty("用户头像")
    @Length(min = 10, max = 255, message = "头像地址长度介于10~255位")
    private String headUrl;

    @ApiModelProperty("上传头像")
    private MultipartFile file;

    @ApiModelProperty("状态")
    private Boolean state = true;

    /**
     * 建议以json格式进行存储
     */
    @ApiModelProperty("其它字段")
    @Length(max = 255, message = "其它字段长度介于0~255位")
    private String other;
}
